<?php
ArrowController::importModel("org.arrowplatform.controls.common.actions.ArrowAbstractUIAction");
class ArrowUIActionsGroup extends ArrowTagContainer{
	
	public function configure(){
		$this->addProperties(array(
			"name" => null
		));
		$this->setDisplay(false);
	}
	
	public function getActions(){
		return $this->getChildren("ArrowAbstractUIAction");
	}
	
	public function getAllowedActions( $modelActions ){
		$modelActionsTmp = array();
		foreach( $modelActions as $action ){
			$modelActionsTmp[$action->getId()] = $action;	
		}
		
		
		$actionsToReturn = array();
		foreach( $this->getActions() as $action ){
			if( $action->getProperty("checkAccess") == "0" ){
				$actionsToReturn[] = $action;
				continue;
			}
			
			$id = $action->getId();
			if(!isset($modelActionsTmp[$id])){
				throw new ArrowException(
					array( "msg" => "Model do not define action '".$id."'" )
				);
			}
			if(  $modelActionsTmp[$id]->isAllowed()){
				$actionsToReturn[] = $action;
			}
		}
		return $actionsToReturn;
	}
}
?>